#include "sz9_protocol_helper.h"
#include "loadrtu_runtime.h"

uint16 sz9_hton(uint16 data)
{
  uint8 low = (uint8)data;
  uint8 high = (uint8)(data >> 8);
  return ((uint16)low << 8) | high;
}
// network to host
uint16 sz9_ntoh(uint16 data)
{
  return sz9_hton(data);
}

void sz9_fill_frame_head(SZ9_FRAME_HEAD_T* head, uint16 function_code)
{
  head->device_id = g_runtime.info.device_parameter.device_id;
  head->device_type = sz9_hton(g_runtime.info.device_parameter.device_type);
  head->function_code = sz9_hton(function_code);
  head->location = g_runtime.info.device_parameter.location;
  head->manufacturer = sz9_hton(g_runtime.info.device_parameter.manufacturer);
  head->protocol_type = sz9_hton(g_runtime.info.device_parameter.protocol_type);
}
